﻿using System;
using System.Diagnostics.Contracts;

namespace RobotRules.Cache
{
    [ContractClassFor(typeof(ICache))]
    abstract class CacheContract : ICache
    {
        protected CacheContract()
        {
        }

        protected CacheContract(TimeSpan cacheTimeout)
        {
            Contract.Requires<ArgumentOutOfRangeException>(cacheTimeout != TimeSpan.Zero, "cacheTimeout cannot equals TimeSpan.Zero");
        }

        public void Add(Uri url, string[] content)
        {
            Contract.Requires<ArgumentNullException>(url != null, "url cannot be null");
            Contract.Requires<ArgumentException>(content != null && content.Length != 0, "content cannot be null or empty");
        }

        public void Delete(Uri url)
        {
            Contract.Requires<ArgumentNullException>(url != null, "url cannot be null");
        }

        public DateTime? GetDate(Uri url)
        {
            Contract.Requires<ArgumentNullException>(url != null, "url cannot be null");

            return null;
        }

        public void Update(Uri url, string[] content)
        {
            Contract.Requires<ArgumentNullException>(url != null, "url cannot be null");
            Contract.Requires<ArgumentException>(content != null && content.Length != 0, "content cannot be null or empty");

        }

        public bool Exists(Uri url)
        {
            Contract.Requires<ArgumentNullException>(url != null, "url cannot be null");

            return default(bool);
        }

        public string[] GetFile(Uri url)
        {
            Contract.Requires<ArgumentNullException>(url != null, "url cannot be null");
            return null;
        }

        public void Clear()
        {
        }

        public void Dispose()
        {
        }
    }
}
